<template>
  <div class="app-container">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="name" label="审核名称"> </el-table-column>
      <el-table-column prop="type" label="审核类型"> </el-table-column>
      <el-table-column prop="status" label="审核状态"> </el-table-column>
      <el-table-column prop="review" label="结果状态"> </el-table-column>
      <el-table-column prop="refuseReason" label="拒绝原因"> </el-table-column>
      <el-table-column prop="action" label="操作">
        <template slot-scope="scope">
          <el-button
            @click="handleClick(scope.row, 'delete')"
            type="text"
            size="small"
            >删除</el-button
          >
          <el-button
            type="text"
            size="small"
            @click="handleClick(scope.row, 'edit')"
            >编辑</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination
        layout="prev, pager, next"
        :total="total"
        :page-size="pagesize"
        :current-page="page"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {
  listReagentReview,
} from '@/api/reagent/review'
export default {
  name: 'Buy',
  data() {
    return {
      tableData: [],
      isEdit: false,
      editId: '',
      total: 0,
      page: 1,
      pagesize: 10,
    }
  },
  created() {
    this.getReagentReview()
  },
  methods: {
    getReagentReview() {
      const self = this
      listReagentReview({pageNum: self.page, pageSize: self.pagesize}).then((response) => {
        if (response && response.rows) {
          self.tableData = response.rows
        }
      })
    },
    handleClick(row, type) {
      const self = this
      if (type === 'delete') {
        self
          .$confirm('此操作将永久删除该仓库, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
          .then(() => {
            delReagentBuy(row.id).then((response) => {
              if (response && response.code === 200) {
                self.$message({
                  message: '操作成功',
                  type: 'success',
                })
                self.getReagentBuy()
              }
            })
          })
      } else if (type === 'edit') {
        self.isEdit = true
        self.editId = row.id
        self.form = {
          ...row,
        }
        self.dialogFormVisible = true
      }
    },
  },
}
</script>

<style></style>
